/*
 * @Author: xiaosihan
 * @Date: 2022-07-11 07:51:56
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-06-07 01:27:03
 */

import hashHistory from '@hashHistory';
import { Button } from 'antd';
import { autorun } from 'mobx';
import { useEffect, useState } from 'react';
import home2Store from './home2Store';
import styles from './index.module.less';

const Home2 = () => {
  const [storeValue, setStoreValue] = useState(home2Store.value);

  useEffect(() => {
    const disposer = autorun(() => {
      const { value } = home2Store;
      setStoreValue(value);
    });
    return () => disposer(); // 组件销毁时，必须清除监听 autorun
  }, []);

  return (
    <div>
      <div>全局任意组件监听： {storeValue}</div>
    </div>
  );
};

export default Home2;
